<?php

namespace app\admin\model\activtyc;

use think\Model;
use app\admin\model\base\Single as base_single;

class Single extends Model
{
    // 表名
    protected $name = 'single_family';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    
    // 追加属性
    protected $append = [
        'pay_text'
    ];
    

    
    public function getPayList()
    {
        return ['0' => __('Pay 0'),'1' => __('Pay 1'),'2' => __('Pay 2')];
    }     


    public function getPayTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['pay'];
        $list = $this->getPayList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTypeList(){
        return array_column(collection(base_single::field('id,name,title,publish,z_publish')->select())->toArray(), 'name','id');
    }

}
